package start.demo01;

import org.junit.Test;

public class Sort {

    @Test
    public void bubble(){
        int[] a=new int[]{5,2,3,7,1,6,4,8,9};
        for (int i = 0; i < a.length - 1; i++) {
            boolean s=false;//设置标记
            for (int j = 0; j < a.length-1-i; j++) {
                if(a[j]>a[j+1]){
                    int k=a[j];
                    a[j]=a[j+1];
                    a[j+1]=k;
                    s=true;
                }
            }
            if(!s)break;
        }
        for (int i : a) {
            System.out.print(i);
        }
    }
}
